window.onload = function() {
    //获取username文本框id
    var elUsername = document.getElementById("username"),
        usernameErrorSpan = document.getElementById("usernameError"),
        elPassword = document.getElementById("password"),
        passwordErrorSpan = document.getElementById("passwordError")

    /*给用户名文本框绑定失去焦点事件*/
    elUsername.onblur = function () {
        //获取用户名
        var username = elUsername.value.trim();
        if(username == ""){
            usernameErrorSpan.innerText = "用户名不能为空"
        }
    }

    elPassword.onblur = function () {
        //获取用户名
        var password = elPassword.value.trim();
        if(password == ""){
            passwordErrorSpan.innerText = "密码不能为空"
        }
    }
}